#!/bin/bash

export ROOT_DIR=~/dev/glsdsp++/samebatch-multiproduct-binpacking-mpi/trunk

cd $ROOT_DIR

if [ "$2" != "" ]
then
	datafullfilename=$(basename $2)
	datafilename=${datafullfilename%.*}
	dataextension=${datafullfilename##*.}

	echo "datafullfilename=$datafullfilename"
	echo "datafilename=$datafilename"
	echo "dataextension=$dataextension"
	
	if [ -f $2 ]
	then
		echo "##############################################################################"
		echo "time bin/samebatch-multiproduct-binpacking $1 $2 $3 $4 $5 $6 $7 $8 $9 > log/$datafilename.log"
		/usr/bin/time -f " real \t %E s \n user \t %U s \n sys \t %S s" -o log/$datafilename.time bin/samebatch-multiproduct-binpacking $1 $2 $3 $4 $5 $6 $7 $8 $9 > log/$datafilename.log
		echo "" >> log/$datafilename.log
		cat log/$datafilename.time >> log/$datafilename.log
		rm  log/$datafilename.time
		cat log/$datafilename.log
	else
		echo ""
		echo "ERROR : file $2 does not exist" 
		echo "ERROR : file $2 does not exist" > log/erreur.log
		echo ""
	fi

else
	echo ""
	echo Usage : $0 -bbp data/instance040c1.txt 
	echo Usage : $0 -bbp data/instance040c1.txt > log/erreur.log
	echo ""
fi


echo FIN DU SCRIPT
exit

